package com.battle.service.controller.web;

import com.battle.pojo.param.warCaseStudyDetails.*;
import com.battle.pojo.vo.warCaseStudyDetails.*;
import com.battle.service.service.in.*;
import nirvana.core.domains.vo.PageResult;
import nirvana.core.domains.vo.ApiResult;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.Valid;

import java.util.List;

/**
 * web/战例研讨记录
 * 【描 述】：
 * 【环 境】：J2SE
 * 【详 细】：
 */
@RestController
@RequestMapping("/warCaseStudyDetails/web")
public class WarCaseStudyDetailsWebController {

    private final WarCaseStudyDetailsService service;

    public WarCaseStudyDetailsWebController(WarCaseStudyDetailsService service) {
        this.service = service;
    }


    /**
     * 创建战例研讨记录
     *
     * @param param
     * @return
     */
    @PostMapping("/createWarCaseStudyDetails")
    public ApiResult createWarCaseStudyDetails(@RequestBody @Valid CreateWarCaseStudyDetailsParam param) {
        service.createWarCaseStudyDetails(param);
        return ApiResult.ok();
    }


    /**
     * 点赞
     *
     * @param id
     */
    @GetMapping("/upvoteNumber")
    public ApiResult upvoteNumber(@RequestParam("id") Long id) {
        service.upvoteNumber(id);
        return ApiResult.ok();
    }

    /**
     * 置顶|取消置顶
     *
     * @param id
     */
    @GetMapping("/topNumber")
    public ApiResult topNumber(@RequestParam("id") Long id) {
        service.topNumber(id);
        return ApiResult.ok();
    }


    /**
     * 移除战例研讨记录
     *
     * @param id
     */
    @DeleteMapping("/removeWarCaseStudyDetails")
    public ApiResult removeWarCaseStudyDetails(@RequestParam("id") Long id) {
        service.removeWarCaseStudyDetails(id);
        return ApiResult.ok();
    }

    /**
     * 获取战例研讨记录详情
     *
     * @param id
     * @return
     */
    @GetMapping("/getWarCaseStudyDetails")
    public ApiResult<GetWarCaseStudyDetailsVo> getWarCaseStudyDetails(@RequestParam("id") Long id) {
        GetWarCaseStudyDetailsVo vo = service.getWarCaseStudyDetails(id);
        return ApiResult.ok(vo);
    }

    /**
     * 获取战例研讨记录列表
     *
     * @param param
     * @return
     */
    @PostMapping("/getWarCaseStudyDetailsList")
    public ApiResult<PageResult<GetWarCaseStudyDetailsListVo>> getWarCaseStudyDetailsList(@RequestBody GetWarCaseStudyDetailsListParam param) {
        PageResult<GetWarCaseStudyDetailsListVo> result = service.getWarCaseStudyDetailsList(param);
        return ApiResult.ok(result);
    }


}

